<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>进行考核</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">

    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link type="text/css" rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">

    <script src="/js/common/language.js"></script>

    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" charset="utf-8" src="/lib/pagination/js/jquery.pagination.min.js"></script>

    <%--<script src="/js/document/makeADraft.js"></script>--%>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>

        table tr {
            border-width: 1px;
            border-style: solid;
            border-color: rgb(204, 204, 204);
            border-image: initial;
        }
        table tr th {
            font-size: 13pt;
            color: rgb(47, 92, 143);
            text-align: center;
            padding: 6px;
        }

        table  td {
            font-size: 11pt;
            padding: 6px;
            height: 30px;
            line-height: 30px;
            text-align: center;
            word-break: keep-all;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
        table tr:nth-child(2n) {
            background-color: rgb(255, 255, 255);
        }
        table tr:nth-child(2n+1) {
            background-color:#F6F7F9 ;
        }
        textarea.BigStatic {
            font-size: 10pt;
            padding: 1px 5px;
            border: 1px solid #C0BBB4;
            background: #E0E0E0;
            margin-left: 32px;
        }
        .li-set p{
            margin: 5px 0 0 103px;
        }
        .M-box3 .active {
            margin: 0px 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            background: #2b7fe0;
            font-size: 12px;
            border: 1px solid #2b7fe0;
            color: #fff;
            text-align: center;
            display: inline-block;
        }
        .M-box3 {
            margin-top: 30px;
            position: fixed;
            bottom: 10px;
            right: 60px;
            text-align: center;
        }
        .M-box3 a {
            margin: 0 3px;
            width: 38px;
            height: 38px;
            line-height: 38px;
            font-size: 12px;
            display: inline-block;
            text-align: center;
            background: #fff;
            border: 1px solid #ebebeb;
            color: #333;
            text-decoration: none;
        }
        body{
            overflow-y: auto;
        }
    </style>
</head>
<body>
<div class="head-top">
    <ul class="clearfix">
        <li class="fl head-top-li doing active" data-type="0">考核中</li>
        <li class="fl head-top-img"><img src="/img/twoth.png" alt=""></li>
        <li class="fl head-top-li over" data-type="1">考核完成</li>
    </ul>
</div>
<table style="margin:65px auto;width:95%">
    <thead>
    <tr style="background: none">
        <th>考核单位</th>
        <th>考核任务名称</th>
        <th>考核试卷名称</th>
        <th>生效日期</th>
        <th class="enddata">终止日期</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>

    </tbody>
</table>
<div id="dbgz_page" class="M-box3">

</div>

<script>
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }

    $('.head-top li').click(function () {
        $(this).siblings('li').removeClass('active')
        $(this).addClass('active')
        if($(this).attr('data-type')=='0'){
            ajaxPageTr.data.page=1;
            ajaxPageTr.data.status=0;
            ajaxPageTr.page();
        }else if($(this).attr('data-type')=='1'){
            ajaxPageTr.data.page=1;
            ajaxPageTr.data.status=1;
            ajaxPageTr.page();
        }
    })

    var status="";
    //列表带分页
    function undefindData(data) {
        if(data == undefined){
            return '';
        }else{
            return data;
        }
    }
    function undefindData1(data) {
        if(data == undefined){
            return '<span status="1" ></span>';
        }else{
            var datatime = data + "";
            var daTi = new Date (datatime).getTime();
            var noTi = new Date().getTime();
            if(daTi<noTi){

                return '<span status="2" style="color:red;font-weight: bold">'+data+'(超时)</span>';
            }else {
                return '<span status="1" style="color: black" >'+data+'</span>';
            }
        }
    }
    var ajaxPageTr={
        data:{
            page:1,//当前处于第几页
            pageSize:5,//一页显示几条
            useFlag:true,
            ifAssessment:"1",
            status:0
        },
        page:function () {
            var me=this;
            layer.msg('加载中', {
                icon: 16
                ,shade: 0.01
            });
            $.ajax({
                type:'get',
                url:'/ScoreFlowLeader/selMyFlows',
                dataType:'json',
                data:me.data,
                success:function(res){
                    if(res.code==0){
                        var str='';

                        $.each(res.data, function (index, item) {
                            var display = '';
                            var showoper ='';
                            if(item.status==1||item.status==2){
                                showoper = '已完成'
                                str += '<tr groupId="'+item.groupId+'" flowId="'+item.flowId+'">' +
                                    '<td title="'+undefindData(item.assessmentUnitName)+'">' + undefindData(item.assessmentUnitName)+ '</td>' +
                                    '<td title="'+item.flowTitle +'">' + item.flowTitle + '</td>' +
                                    '<td title="'+undefindData(item.groupName)+'"><a href="javascript:;" class="kaohegroupName">' + undefindData(item.groupName)+ '</a></td>' +
                                    '<td title="'+undefindData(item.beginDate)+'">' + undefindData(item.beginDate)+ '</td>' +
                                    '<td title="'+undefindData(item.endDate)+'">' +undefindData(item.endDate) + '</td>' +
                                    '<td ><a href="javascript:;" class="kaoheList" type="2" >'+showoper+'</a></td>' +
                                    '</tr>';
                            }else if(item.status==0){
                                showoper = '考核'
                                str += '<tr groupId="'+item.groupId+'" flowId="'+item.flowId+'">' +
                                    '<td title="'+undefindData(item.assessmentUnitName)+'">' + undefindData(item.assessmentUnitName)+ '</td>' +
                                    '<td title="'+item.flowTitle +'">' + item.flowTitle + '</td>' +
                                    '<td title="'+undefindData(item.groupName)+'"><a href="javascript:;" class="kaohegroupName">' + undefindData(item.groupName)+ '</a></td>' +
                                    '<td title="'+undefindData(item.beginDate)+'">' + undefindData(item.beginDate)+ '</td>' +
                                    '<td title="'+undefindData(item.endDate)+'">' +undefindData1(item.endDate) + '</td>' +
                                    '<td ><a href="javascript:;" class="kaoheList" type="1" >'+showoper+'</a></td>' +
                                    '</tr>';
                            }


                        })
                        $('tbody').html(str)
                        layer.closeAll();
                        me.pageTwo(res.totleNum,me.data.pageSize,me.data.page)


                    }else{
                        layer.msg("暂无数据", {icon: 2})
                    }

                }
            })

        },
        pageTwo:function (totalData, pageSize,indexs) {
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                prevContent:'上一页',
                nextContent:'下一页',
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    }


    var type = getQueryString("type");

    if(type==2){
        ajaxPageTr.data.status=1;
        ajaxPageTr.page();
        $('.doing').removeClass('active')
        $('.over').addClass('active');
    } else {
        ajaxPageTr.page();
    }


    $('table').on('click','.kaohegroupName',function(){
        var groupId=$(this).parent().parent().attr('groupId')
        layer.open({
            title: ['考核项目', 'background-color:#2b7fe0;color:#fff;'],
            area: ['500px', '350px'],
            shadeClose: false, //点击遮罩关闭
            content: ' <table><thead><tr><th>考核项目</th><th>分值范围</th><th>描述</th></tr></thead><tbody id="bodywarp"></tbody></table>',
            btn: ['取消'],
            success:function(){
                $.ajax({
                    type:'get',
                    url:'/ScoreItemLeader/selScoreItem',
                    dataType:'json',
                    data:{
                        groupId:groupId
                    },
                    success:function(res){
                        var str='';
                        $.each(res.obj, function (index, item) {
                            str += '<tr groupId="'+item.groupId+'" flowId="'+item.flowId+'">' +
                                '<td title="'+item.itemName+'">' + item.itemName+ '</td>' +
                                '<td>' + item.min +' ~ '+item.max+ '</td>' +
                                '<td title="'+item.itemExplain +'">' + item.itemExplain + '</td>' +
                                '</tr>';

                        })
                        $('#bodywarp').html(str)
                    }
                });
            },
            yes:function(index){
                layer.close(index);
            }
        })
    });
    //考核跳转
    $('table').on('click','.kaoheList',function(){
        var status=$(this).parent().parent().find("span").attr("status");
        var flowId=$(this).parent().parent().attr('flowId')
        var type = $(this).attr("type");
        location.href='/ScoreFlowLeader/kaoheList?flowId='+flowId+'&type='+type;
    });
    //获取当前时间  年月日
    function nowformat() {
        var  nstr = "";
        var now = new Date();
        var nyear = now.getFullYear();
        var nmonth = now.getMonth()+1;
        var nday = now.getDate();
        if(nmonth<10){
            nmonth = "0"+nmonth;
        }
        if(nday<10){
            nday = "0"+nday;
        }
        nstr = nyear+"-"+nmonth+"-"+nday;
        return nstr;
    }

</script>
</body>
</html>




